// 评论相关 API 接口定义
import { get, post } from '@/utils/request';
import type {
  GetCommentsParams,
  GetCommentsResponse,
  PublishCommentParams,
  LikeCommentParams,
  DislikeCommentParams,
  MarkCommentParams,
  UpdateCommentParams,
  CommentActionResponse,
} from '@/types/comment';

/**
 * 获取评论列表
 */
export const getComments = (params: GetCommentsParams, xLogId: string) => {
  return get<GetCommentsResponse>('/comment/c/getComments', params, {
    'X-Log-ID': xLogId,
  });
};

/**
 * 发布评论
 */
export const publishComment = (params: PublishCommentParams, xLogId: string) => {
  return post<CommentActionResponse>('/comment/c/publishComment', params, {
    'X-Log-ID': xLogId,
  });
};

/**
 * 点赞/取消点赞评论
 */
export const likeComment = (params: LikeCommentParams, xLogId: string) => {
  return post<CommentActionResponse>('/comment/c/like', params, {
    'X-Log-ID': xLogId,
  });
};

/**
 * 点踩/取消点踩评论
 */
export const dislikeComment = (params: DislikeCommentParams, xLogId: string) => {
  return post<CommentActionResponse>('/comment/c/dislike', params, {
    'X-Log-ID': xLogId,
  });
};

/**
 * 收藏/取消收藏评论
 */
export const markComment = (params: MarkCommentParams, xLogId: string) => {
  return post<CommentActionResponse>('/comment/c/mark', params, {
    'X-Log-ID': xLogId,
  });
};

/**
 * 修改评论
 */
export const updateComment = (params: UpdateCommentParams, xLogId: string) => {
  return post<CommentActionResponse>('/comment/c/updateComment', params, {
    'X-Log-ID': xLogId,
  });
};
